package repositories

import (
	"gitlab-dingtalk/server/config/db"
	"gitlab-dingtalk/server/model"
)

var SysUserRepositories = newSysUserRepositories()

func newSysUserRepositories() *sysUserRepositories {
	return &sysUserRepositories{}
}

type sysUserRepositories struct {
}

func (r *sysUserRepositories) FindUserByName(name string) (*model.User, error) {
	user := &model.User{}
	if err := db.Db().Table("sys_user").Where("nickname = ? and delete_status = ?", name, "1").Take(user).Error; err != nil {
		return nil, err
	}
	return user, nil
}
